﻿@model List<Schedule>
@{
    string? search = (string)ViewData["search"];
}
<h1>安排列表</h1>
<form asp-action="Index" method="get">
    <input name="search" type="text" required value="@search"/>
    <input type="submit" value="搜索" />
    @if (!string.IsNullOrEmpty(search))
    {
        <a asp-action="Index">清空搜索</a>
    }
</form>
<a asp-action="Add">新建安排</a>
<table class="table">
    <tr>
        <th>
            会员卡号
        </th>
        <th>
            手机号
        </th>
        <th>
            备注
        </th>
        <th>
            创建日期
        </th>
        <th>
            到期日期
        </th>
        <th></th>
    </tr>
    @foreach(var s in Model)
    {
        int days = (int)(s.Target - DateTime.Now).TotalDays;
        <tr>
            <td>
                @s.Name
            </td>
            <td>
                @s.Tel
            </td>
            <td>
                @s.Remark
            </td>
            <td>
                @s.Created.ToString("yyyy-MM-dd")
            </td>
            <td>
                @s.Target.ToString("yyyy-MM-dd")
                <b>[@(days)天]</b>
            </td>
            <td>
                <a asp-action="Duplicate" asp-route-id="@s.Id">复制</a>
                <a asp-action="Edit" asp-route-id="@s.Id">编辑</a>
            </td>
        </tr>
    }
</table>